gtk/meson: Read dirs from options
authorTimm Bäder <mail@baedert.org>
Sat, 24 Sep 2016 08:04:23 +0000 (10:04 +0200)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 3 May 2017 14:10:52 +0000 (15:10 +0100)
gtk/meson.build

index 1e350d3e2301c6706afef6310de8c2f8bf0f850d..80ad82d87382819aede94b4ca9a6f6ae8f60bcf0 100644 (file)
@@ -766,6 +766,17 @@ gtkversion = configure_file(
   configuration: cdata
 )
 
+gtk_cargs = [
+  '-DGTK_COMPILATION',
+  '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
+  '-DGTK_BINARY_VERSION="' + gtk_binary_version + '"',
+  '-DGTK_HOST="' + host_machine.system() + '"',
+  '-DGTK_SYSCONFDIR="' + get_option('prefix') + '/etc"',
+  '-DGTK_DATADIR="' + get_option('datadir') + '"',
+  '-DGTK_DATA_PREFIX="'+ get_option('prefix') + '"',
+  '-DGTK_PRINT_BACKENDS="null"',
+]
+
 gtk_sources += [
   gtk_dbus_src,
   gtk_unix_sources,
@@ -796,6 +807,13 @@ gtk_deps = [
 ]
 
 if x11_enabled
+  runcmd = run_command('pkg-config', '--variable=pkgdatadir', 'wayland-protocols')
+  if runcmd.returncode() == 0
+      gtk_cargs += '-DX11_DATA_PREFIX="' + runcmd.stdout().strip() + '"'
+  else
+    error('Could not get wayland-protocols pkgdatadir via pkg-config.')
+  endif
+
   gtk_sources += [
     gtk_x11_sources,
     gtk_use_wayland_or_x11_c_sources
@@ -820,16 +838,7 @@ endif
 libgtk = shared_library('gtk',
   gtk_sources,
   gtkmarshal_h,
-  c_args: [
-    '-DGTK_COMPILATION',
-    '-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
-    '-DGTK_BINARY_VERSION="' + gtk_binary_version + '"',
-    '-DGTK_HOST="' + host_machine.system() + '"',
-    '-DGTK_SYSCONFDIR="sysconfdir"',
-    '-DGTK_DATA_PREFIX="dataprefix"',
-    '-DGTK_PRINT_BACKENDS="null"',
-    '-DX11_DATA_PREFIX="/usr"'
-  ],
+  c_args: gtk_cargs,
   include_directories: [ confinc, gdkinc, gtkinc ],
   dependencies: [gtk_deps, libgdk_dep],
 )